#include <QDBusConnection>
#include <QDebug>
#include "keyboard.h"
#include "interface.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QFile qssFile(":/kbd.qss");
    if(qssFile.open(QIODevice::ReadOnly)) {
        qApp->setStyleSheet(qssFile.readAll());
        qssFile.close();
    }

    Keyboard kbd;
    Interface dbusInf(&kbd);
    auto session = QDBusConnection::sessionBus();
    bool result = session.registerService("com.kylin.arrowkbd");
    if (!result) {
        qWarning() << "register service failed";
        return -1;
    }

    result = session.registerObject("/com/kylin/arrowkbd", &kbd);
    if (!result) {
        qWarning() << "register object failed";
        return -1;
    }
    return a.exec();
}
